//
//  ExaminaColumnHeaderWithSectionView.m
//  Coach_HaiGeEr
//
//  Created by liuchen on 2018/10/19.
//  Copyright © 2018年 海格尔. All rights reserved.
//

#import "ExaminaColumnHeaderWithSectionView.h"
@interface ExaminaColumnHeaderWithSectionView()
@property (nonatomic,assign) NSInteger section;
@end

@implementation ExaminaColumnHeaderWithSectionView

- (instancetype)initWithFrame:(CGRect)frame WithType:(NSInteger)type WithTitle:(NSString *)title WithSection:(NSInteger)section{
    self = [super initWithFrame:frame];
    if (self) {
        //创建视图
        [self createSubViewWithType:type WithTitle:title WithSection:section];
    }
    return self;
}

#pragma mark ==========创建视图==========
- (void)createSubViewWithType:(NSInteger)type WithTitle:(NSString *)title WithSection:(NSInteger)section{//1带间隔线 0不带间隔线
    self.section = section;
    self.backgroundColor = [UIColor colorWithHexString:@"#eeeeee"];
    UIView *backView = [[UIView alloc] init];
    backView.backgroundColor = [UIColor whiteColor];
    [self addSubview:backView];
    
    UILabel *titleLebl = [[UILabel alloc] init];
    titleLebl.backgroundColor  = [UIColor clearColor];
    titleLebl.text = title;
    titleLebl.textAlignment = NSTextAlignmentLeft;
    titleLebl.font = [UIFont systemFontOfSize:LoginFont-3];
    titleLebl.textColor = [UIColor colorWithHexString:@"282828"];
    [backView addSubview:titleLebl];
    
    UIButton *actionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [actionBtn setTitle:@"收起" forState:UIControlStateNormal];
    [actionBtn setTitle:@"展开" forState:UIControlStateSelected];
    //[actionBtn setImage:[UIImage imageNamed:@"选择城市箭头"] forState:UIControlStateNormal];
    //[actionBtn setImage:[UIImage imageNamed:@"选择城市箭头"] forState:UIControlStateSelected];
    [actionBtn.titleLabel setFont:[UIFont systemFontOfSize:LoginFont-4]];
    [actionBtn setTitleColor:[UIColor colorWithHexString:@"#999999"] forState:UIControlStateNormal];
    actionBtn.tag = 10000+section;
    _actionBtn = actionBtn;
    [backView addSubview:self.actionBtn];
    
    UILabel *lineLabel = [[UILabel alloc] init];
    lineLabel.backgroundColor = [UIColor colorWithHexString:@"#eeeeee"];
    [backView addSubview:lineLabel];
    
    WS(ws);
    [backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws);
        make.top.mas_equalTo(ws).with.offset(20*SCALEUNIT*type);
        make.right.mas_equalTo(ws);
        make.bottom.mas_equalTo(ws);
    }];
    [titleLebl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws).with.offset(25*SCALEUNIT);
        make.top.height.mas_equalTo(backView);
        make.width.mas_equalTo(400*SCALEUNIT);
    }];
    [actionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(backView).with.offset(-25*SCALEUNIT);
        make.centerY.mas_equalTo(backView);
        make.size.mas_equalTo(CGSizeMake(100*SCALEUNIT, 90*SCALEUNIT));
    }];
    [lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(backView).with.offset(30*SCALEUNIT);
        make.right.mas_equalTo(backView).with.offset(-30*SCALEUNIT);
        make.bottom.mas_equalTo(backView);
        make.height.mas_equalTo(SCALEUNIT);
    }];
}





@end
